class Solution424 {
    public int characterReplacement(String s, int k) {
           int len = s.length() ;
           char[] arr  = s.toCharArray() ;
           int[] hash = new int[26] ; 
           int left= 0 ; 
           int right = 0 ;
           int maxCount = 0 ;
           int maxLen = 0 ;   
           while(right < len){
               hash[arr[right]-'A'] ++ ;
              
               maxCount = Math.max(maxCount , hash[arr[right]-'A']) ; 
                right ++ ;
               if(right-left > maxCount+k){
                  hash[arr[left]-'A'] -- ; 
                   left ++ ;
               }
               maxLen = Math.max(maxLen , right - left) ; 
           }
          return maxLen ; 
    }
}